{extend name="public/base" /}
{block name="title"}收货地址{/block}
{block name="content"}
<div id="shouHuoDiZhi">
    <div class="shdz-shouhuo-address-first">
        {volist name="address" id="vo"}
        <div class="shdz-s-d-item">
            <div class="shdz-s-d-item-left address-item" data-id="{$vo.id}" data-order="{$preorder ?? ''}">
                <div class="fs16 cl33 fwb tl ls10">
                    <span class="shdz-s-d-item-left-name">{$vo.name}</span>
                    <span class="fs14 cl6e ml5 ls10">{$vo.phone}</span>
                </div>
                <div class="cl33 fs14 tl over2 mt10">
                    {if $vo.is_default}<span class="moren">默认</span>{/if}
                    {$vo.province}{$vo.city}{$vo.district}{$vo.address}
                </div>
            </div>
            <a href="{:route('addressEdit', ['id' => $vo.id])}"><div class="fs14 cldb">编辑</div></a>
        </div>
        {/volist}
    </div>

    <div class="shdz-sub-btn-box tc">
        <button type="button" class="shdz-sub-btn" id="add" data-url="{:route('addressAdd')}">添加新地址</button>
    </div>

</div>
{/block}
{block name="footjs"}
<script type="text/javascript">
    $('#add').click(function(){
        window.location.href = $(this).data('url')
    })

    $('.address-item').on('click', function(){
        var order = $(this).data('order')
        if(order){
            var id = $(this).data('id')
            var orderArr = order.split('_')
            orderArr[2] = id
            // var param = $(this).data('order').replace('_00_', '_'+$(this).data('id')+'_')
            
            var url = "{:route('Order/preSure')}?buy="+orderArr.join('_')
            window.location.replace(url);
        }
    })
    
</script>
{/block}